package de.preisrobot.business.parser.heimpconline;

import java.util.List;

import net.htmlparser.jericho.Element;
import net.htmlparser.jericho.Source;

import de.preisrobot.entity.Tb_Category;

public class HeimPConlineLinkParser
{

   public Tb_Category parseNavigation(Source s)
   {
      Tb_Category root = new Tb_Category();
      root.setName("heim-pc-online");
      
      
      Element divElem = s.getElementById("DropDownList25133408");
      
      
      List<Element> topLevelCategories = divElem.getAllElements("li");
      
      for (Element element : topLevelCategories)
      {
         List<Element> aElem = element.getAllElements("a");
         Element aElement = aElem.get(0);
         
         String categorieLink = aElement.getAttributeValue("href");
         String catName = aElement.getTextExtractor().toString();
         
         Tb_Category cat1 = new Tb_Category();
         cat1.setLink(categorieLink);
         cat1.setName(catName);
         cat1.setParentCategory(root);
         
         root.getChildren().add(cat1);
      }
      
      return root;
   }
}
